from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()

class Cate(db.Model):
    id = db.Column(db.Integer,primary_key = True,autoincrement = True)
    name = db.Column(db.String(50),unique = True,nullable = False)

    goods = db.relationship("Goods",backref = "cate")

class Goods(db.Model):
    id = db.Column(db.Integer,primary_key = True,autoincrement = True)
    name = db.Column(db.String(150),unique = True,nullable = False)
    price = db.Column(db.Integer,nullable = False,default = 1)
    count = db.Column(db.Integer,default = 0)
    photo = db.Column(db.String(150))
    cate_id = db.Column(db.Integer, db.ForeignKey('cate.id'))